package hihocoder;
/**
 * 
 */


import java.util.Scanner;

/**
 * @author zhongfang
 *
 */
public class 逆序对 {

	static int count=0;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int N=scanner.nextInt();
		int[] A=new int[N];
		for (int i = 0; i < N; i++) {
			A[i]=scanner.nextInt()-1;
		}
		int[] tmp=new int[N];
		mergeSort(A,0,N-1,tmp);
		System.out.println(count);
	}

	private static void mergeSort(int[] a, int first, int last, int[] tmp) {
		if(first<last){
			int mid=(first+last)>>1;
			mergeSort(a, first, mid, tmp);
			mergeSort(a, mid+1, last, tmp);
			mergeCount(a,first,mid,last,tmp);
		}
	}

	private static void mergeCount(int[] a, int first, int mid, int last, int[] tmp) {
		int i=first;
		int j=mid+1;
		int k=0;
		while (i<=mid&&j<=last) {
			if(a[i]>a[j]){
				tmp[k++]=a[j++];
				count+=(mid-i+1);
			}else {
				tmp[k++]=a[i++];
			}
		}
		while (i<=mid) {
			tmp[k++]=a[i++];
		}
		while (j<=last) {
			tmp[k++]=a[j++];
		}
		for (int k2 = 0; k2 < k; k2++) {
			a[first+k2]=tmp[k2];
		}
	}
}
